/**
 * 物料管理数据model
 */
import {lineUpSave,lineUpPassAndScore,lineUpPass,lineUnPass,getEovlveList,
    lineUpBatchPass,getLineUpPage
} from 'api/lessonManageApi';

const lineUpManage = {
    state: {
        lineUpManagePageData:[],
        labEvolveList:[],
        page: {
            currentPage: 1,
            pageSize: 5,
            total: 0
        },
        queryPara:{
            name: '',
            state: '',
            classTId: '',
            stage: '',
        }
    },
    mutations: {
        loadLineUpManageMut(state, obj){
            if (obj.rows !== '') {
                state.lineUpManagePageData = obj.rows;
                state.page.currentPage = obj.currentPage;
                state.page.pageSize = obj.pageSize;
                state.page.total = obj.total;
            }
        },
        loadLabEvolveListMut(state, obj){
            if (obj.code === 0) {
                if (obj.data && obj.data.length > 0){
                    state.labEvolveList = obj.data;
                }

            }
        },
        setLineUpManageQueryPrams(state, obj){
            state.queryPara = obj;
        }

    },
    actions: {
        /*获取分页列表*/
        getLineUpManagePageListAct (context, para) {
            return getLineUpPage(para).then(res => {
                context.commit("loadLineUpManageMut",res.data);
            });
        },
        loadLabEvolveListAct (context, para) {
            return getEovlveList(para).then(res => {
                return res.data;
            });
        },
        lineUpSaveAct (context, para) {
            return lineUpSave(para).then(res => {
                return res.data;
            });
        },lineUpPassAndScoreAct (context, para) {
            return lineUpPassAndScore(para).then(res => {
                return res.data;
            });
        },lineUpPassAct (context, para) {
            return lineUpPass(para).then(res => {
                return res.data;
            });
        },lineUpUnPassAct (context, para) {
            return lineUnPass(para).then(res => {
                return res.data;
            });
        },lineUpBatchPassAct (context, para) {
            return lineUpBatchPass(para).then(res => {
                return res.data;
            });
        }
    }
};

export default lineUpManage;
